#pragma once
#include "DTransform.h"
#include "../DSpace.h"

namespace Skill
{
	namespace Ode
	{		
		namespace Geometries
		{
			void DTransform::CollectManagedMemory()
			{
				_Geometry = nullptr;
				DGeometry::CollectManagedMemory();
			}

			DTransform::DTransform(DSpace^ space) 
				: DGeometry(space)
			{
				dSpaceID s = space?space->_Space() : NULL;
				_SetPointer(dCreateGeomTransform(s),true);	
				if(_Container)
					_Container->AddSpace(this);
			}
			DGeometry^ DTransform::Geometry::get()
			{
				if(IsSpace) return nullptr;
				return _Geometry;
			}
			void DTransform::Geometry::set(DGeometry^ value)
			{
				if(IsSpace) return;
				_Geometry = value;
				if(_Geometry)
					dGeomTransformSetGeom(_Geom(),_Geometry->_Geom());
				else
					dGeomTransformSetGeom(_Geom(),NULL);
			}

			int DTransform::CleanupMode::get()
			{
				if(IsSpace) return Int32::MinValue;
				return dGeomTransformGetCleanup(_Geom());
			}
			void DTransform::CleanupMode::set(int value)
			{
				if(IsSpace) return;
				dGeomTransformSetCleanup(_Geom(),value);
			}
			int DTransform::Info::get()
			{
				if(IsSpace) return Int32::MinValue;
				return dGeomTransformGetInfo(_Geom());
			}
			void DTransform::Info::set(int value)
			{
				if(IsSpace) return;
				dGeomTransformSetInfo(_Geom(),value);
			}
		}
	}
}